<template>
  <div>
  <el-dialog
    title="审核"
    :visible.sync="dialogVisible"
    center
    width="40%"
    :before-close="handleClose">
    <div>
    <el-card>
    <el-form :model="userCheck" ref="userCheck" :rules="rules">
      <el-form-item label="日期" style="width: 100%">
        <el-col :span="12">
          <el-date-picker type="date" placeholder="选择日期" v-model="userCheck.date" style="width: 55%;"></el-date-picker>
        </el-col>
      </el-form-item>
    </el-form>
    </el-card>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button @click="submitForm()">提 交</el-button>
      <el-button type="primary" @click="handleClose()">关 闭</el-button>
    </div>
  </el-dialog>
  </div>
</template>

<script>
import IdManager from "@/api/dataManage/IdManager";

export default {
  name: "check_user",
  props: {
    userCheck: Object
  },
  data(){
    return {
      dialogVisible: true,
      user: {
        date: null,
      },
      dataManager: {},
      rules: {
        date: [{required: true, message: '请选择一个日期', trigger: 'blur'}],

      }
    }
  },
  created() {
    console.log(this.userCheck)

  },
  methods: {

    handleClose() {
      this.$emit("close", {name: 'check', isRefresh: false});
    },
    submitForm() {
      this.$refs['userCheck'].validate((valid) => {
        if (valid) {
          const loading = this._loading();
          const api = new IdManager();
          console.log(this.userCheck)
          api.updateDate(this.userCheck).then(res => {
            loading.close();
            this.$tie.showSuccess(res.message)
            this.$emit("close", {name: 'check', isRefresh: true});
          }).catch(e => loading.close())
        }
      })
    },
    //加载提示
    _loading() {
      return this.$loading({
        lock: true,
        text: '请耐心等待.....',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
    },

  }
}
</script>

<style scoped>

</style>

